// Fill out your copyright notice in the Description page of Project Settings.

#include "Isalong2.h"

// load here would cause table data broken
UDataTable* ItemType::_itemDisplayDT = nullptr;

float ItemType::GetWeightByID(int id)
{
	switch (id)
	{
	case ITEMTYPE_hand:
		return 0.0f;
	case ITEMTYPE_m9:
		return 6.3f;
	case ITEMTYPE_magrum:
		return 6.7f;
	case ITEMTYPE_tt:
		return 6.2f;
	case ITEMTYPE_mm9:
		return 0.7f;
	case ITEMTYPE_mm7D62:
		return 0.8f;
	case ITEMTYPE_dustWall:
		return 2.0f;
	case ITEMTYPE_baseballBat:
		return 5.0f;
	case ITEMTYPE_crowbar:
		return 4.7f;
	case ITEMTYPE_fireAxe:
		return 7.3f;
	case ITEMTYPE_golfClub:
		return 4.4f;
	case ITEMTYPE_hatchet:
		return 3.6f;
	case ITEMTYPE_kitchenKnife:
		return 2.8f;
	case ITEMTYPE_pipeWrench:
		return 4.2f;
	case ITEMTYPE_shovel:
		return 6.4f;
	case ITEMTYPE_edgehammer:
		return 8.1f;
	case ITEMTYPE_woodStick:
		return 0.6f;
	case ITEMTYPE_treeBlock:
		return 4.0f;
	case ITEMTYPE_bow:
		return 3.2f;
	case ITEMTYPE_arrow:
		return 0.2f;
	case ITEMTYPE_wireBox:
		return 0.18f;
	case ITEMTYPE_canTeen:
		return 2.0f;
	case ITEMTYPE_waterCan:
		return 12.0f;
	case ITEMTYPE_flint:
		return 0.7f;
	case ITEMTYPE_woodSticks:
		return 3.0f;
	case ITEMTYPE_rock:
		return 0.8f;
	case ITEMTYPE_campFire:
		return 12.4f;
	}
	return 0;

}

int ItemType::GetWeaponBoxModeByID(int id)
{
	switch (id)
	{
	case ITEMTYPE_hand:
		return 2;
	case ITEMTYPE_m9:case ITEMTYPE_magrum:case ITEMTYPE_tt:case ITEMTYPE_dustWall:case ITEMTYPE_bow:case  ITEMTYPE_wireBox:
	case ITEMTYPE_campFire:
		return 0;
	case ITEMTYPE_baseballBat:case ITEMTYPE_crowbar: case  ITEMTYPE_fireAxe:case ITEMTYPE_golfClub:
	case ITEMTYPE_hatchet:case ITEMTYPE_kitchenKnife:case ITEMTYPE_pipeWrench:case ITEMTYPE_shovel:case ITEMTYPE_edgehammer:
	case ITEMTYPE_canTeen:case ITEMTYPE_waterCan:
		return 1;
	}
	return 0;
}

bool ItemType::GetIsHoldable(int id)
{
	// the gun // the sword etc
	if (id>=0&&id<=20)
	{
		return true;
	}
	// the building
	if (id>=100&&id<=110)
	{
		return true;
	}
	return false;
}

bool ItemType::GetIsAttachable(int id)
{
	if (id >= 0 && id <= 20)
	{
		return true;
	}
	return false;
}

// this consumable is not the same as the UI consumable, it`s use for indicate the holdable item consumable
bool ItemType::GetIsConsumable(int id)
{
	// the building
	if (id >= 100 && id <= 110)
	{
		return true;
	}
	return false;
}

TArray<int> ItemType::GetReloadNeedType(int id)
{
	TArray<int> result;
	switch (id)
	{
	case ITEMTYPE_m9:
		result.Add(ITEMTYPE_mm9);
		break;
	case ITEMTYPE_magrum:
		result.Add(ITEMTYPE_mm7D62);
		break;
	case ITEMTYPE_dustWall:
		result.Add(ITEMTYPE_dustWall);
		break;
	case ITEMTYPE_campFire:
		result.Add(ITEMTYPE_campFire);
		break;
	case ITEMTYPE_bow:
		result.Add(ITEMTYPE_arrow);
		break;
	case ITEMTYPE_wireBox:
		result.Add(ITEMTYPE_wireBox);
		break;
	case ITEMTYPE_canTeen:
		result.Add(ITEMTYPE_god);
		break;
	case ITEMTYPE_waterCan:
		result.Add(ITEMTYPE_god);
		break;
	}
	return result;
}

string ItemType::GetItemNameByID(int id)
{
	switch (id)
	{
	case ITEMTYPE_hand:
		return "Hand";
	case ITEMTYPE_m9:
		return "M9";
	case ITEMTYPE_magrum:
		return "Magrum";
	case ITEMTYPE_tt:
		return "TT";
	case ITEMTYPE_baseballBat:
		return "baseballBat";
	case ITEMTYPE_crowbar:
		return "crowbar";
	case ITEMTYPE_fireAxe:
		return "fireAxe";
	case ITEMTYPE_golfClub:
		return "golfClub";
	case ITEMTYPE_hatchet:
		return "hatchet";
	case ITEMTYPE_kitchenKnife:
		return "kitchenKnife";
	case ITEMTYPE_pipeWrench:
		return "pipeWrench";
	case ITEMTYPE_shovel:
		return "shovel";
	case ITEMTYPE_edgehammer:
		return "edgehammer";
	case ITEMTYPE_mm7D62:
		return "7.62mm";
	case ITEMTYPE_mm9:
		return "9mm";
	case ITEMTYPE_dustWall:
		return "Dust Wall";
	case ITEMTYPE_woodStick:
		return "Wood Stick";
	case ITEMTYPE_treeBlock:
		return "Tree Block";
	case ITEMTYPE_bow:
		return "Bow";
	case ITEMTYPE_arrow:
		return "Arrow";
	case ITEMTYPE_wireBox:
		return "WireBox";
	case ITEMTYPE_canTeen:
		return "CanTeen";
	case ITEMTYPE_waterCan:
		return "WaterCan";
	case ITEMTYPE_flint:
		return "Flint";
	case ITEMTYPE_woodSticks:
		return "WoodSticks";
	case ITEMTYPE_rock:
		return "Rock";
	case ITEMTYPE_campFire:
		return "CampFire";
	}
	return "unknown";
}

FString ItemType::GetItemFStringNameByID(int id)
{
	return FString(GetItemNameByID(id).c_str());
}

FItemDisplay* ItemType::GetItemDisplayByID(int id)
{
	if (_itemDisplayDT==nullptr)
	{
		_itemDisplayDT=LoadObject<UDataTable>(NULL, TEXT("DataTable'/Game/BrainInVst/DataTables/DisplayItem.DisplayItem'"));
	}
	switch (id)
	{
	case ITEMTYPE_hand:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Hand"), FString(""));
	case ITEMTYPE_m9:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("M9"), FString(""));
	case ITEMTYPE_magrum:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Magrum"), FString(""));
	case ITEMTYPE_tt:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("TT"), FString(""));
	case ITEMTYPE_mm9:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Mm9"), FString(""));
	case ITEMTYPE_mm7D62:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Mm7D62"), FString(""));
	case ITEMTYPE_dustWall:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("DustWall"), FString(""));
	case ITEMTYPE_baseballBat:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("BaseballBat"), FString(""));
	case ITEMTYPE_crowbar:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Crowbar"), FString(""));
	case ITEMTYPE_fireAxe:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("FireAxe"), FString(""));
	case ITEMTYPE_golfClub:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("GolfClub"), FString(""));
	case ITEMTYPE_hatchet:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Hatchet"), FString(""));
	case ITEMTYPE_kitchenKnife:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("KitchenKnife"), FString(""));
	case ITEMTYPE_pipeWrench:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("PipeWrench"), FString(""));
	case ITEMTYPE_shovel:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Shovel"), FString(""));
	case ITEMTYPE_edgehammer:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Edgehammer"), FString(""));
	case ITEMTYPE_woodStick:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("WoodStick"), FString(""));
	case ITEMTYPE_treeBlock:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("TreeBlock"), FString(""));
	case ITEMTYPE_bow:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Bow"), FString(""));
	case ITEMTYPE_arrow:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Arrow"), FString(""));
	case ITEMTYPE_wireBox:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("WireBox"), FString(""));
	case ITEMTYPE_canTeen:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("CanTeen"), FString(""));
	case ITEMTYPE_waterCan:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("WaterCan"), FString(""));
	case ITEMTYPE_flint:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Flint"), FString(""));
	case ITEMTYPE_woodSticks:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("WoodSticks"), FString(""));
	case ITEMTYPE_rock:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("Rock"), FString(""));
	case ITEMTYPE_campFire:
		return _itemDisplayDT->FindRow<FItemDisplay>(FName("CampFire"), FString(""));
	}
	return nullptr;
}
